.TH AFopnWrite 3tsp "TSP (libtsp/AF)"
.SH Routine
.in +4n
.ti -4n
AFILE *AFopnWrite (const char Fname[], int Ftype, int Dtype, long int Nchan,
double Sfreq, FILE *fpinfo)
.in -4n
.SH Purpose
.in +4n
.ti -4n
Open an audio file for writing
.in -4n
.SH Description
This routine opens an audio file for writing.  This routine sets up the audio
file parameters to write data of the given format to the audio file.  After
writing data to the file, the routine AFclose should be called to update the
file header information and close the file.
.PP
By default, information consisting of the date and the program creating the
file (see UTsetProg) is written to the audio file header or trailer.  The
routine AFsetInfo can be called before calling this routine to specify
additional information to be written to the file.
.PP
This routine can write AU audio files, AIFF-C files, WAVE files, and
headerless audio files.
.PP
.in +4n
.ti -4n
AU audio file:
.br
8-bit mu-law, 8-bit A-law, 8/16/24/32-bit integer, and 32/64-bit IEEE
floating-point data formats are supported.
.ti -4n
WAVE file:
.br
8-bit mu-law, 8-bit A-law, offset-binary 8-bit integer, 16/24/32-bit
integer, and 32/64-bit IEEE floating-point, data formats are supported.
.ti -4n
AIFF sound file:
.br
8/16/24/32-bit integer data formats are supported.
.ti -4n
AIFF-C sound file:
.br
8-bit mu-law, 8-bit A-law, 8/16/24/32-bit integer, and 32/64-bit IEEE
floating-point data formats are supported.
.ti -4n
Headerless file:
.br
8-bit mu-law, 8-bit A-law, offset-binary 8-bit integer, 8/16/24/32-bit
integer, 32/64-bit floating-point, and text data formats are supported.
A text format file has the data in character form, one value to a line.
.in -4n
.PP
For the fixed point file data representations, input values in the range
[-1,  +1) ([-.5, +0.5) for 8-bit data) will be converted without clipping.
The scaling factor shown below is applied to the data before they are
written to the file.
.ft CW
.nf
.ne 3
   data format   scaling factor   file data values
  8-bit mu-law    32,768         [-32,124, +32,124]
  8-bit A-law     32,768         [-32,256, +32,256]
  8-bit integer   256            [-128, 127]
  16-bit integer  32,768         [-32,768, +32,767]
  24-bit integer  8,388,608      [-8,388,608, +8,388,607]
  32-bit integer  2,147,483,648  [-2,147,483,648, 2,147,483,647]
.fi
.ft P
For files containing floating-point data, values are scaled by unity before
being written to the file.
.SH Parameters
.in +4n
.ti -4n
<-  AFILE *AFopnWrite
.br
Audio file pointer for the audio file
.ti -4n
 -> const char Fname[]
.br
Character string specifying the file name.  The file name "-" means
standard output.
.ti -4n
 -> int Ftype
.br
Output file type code
.ft CW
.nf
.ne 3
  FTW_AU        = 1,      AU audio file
  FTW_WAVE      = 2,      WAVE file (auto extensible format)
  FTW_WAVE_NOEX = 2 + 16, WAVE file (no extensible format)
  FTW_AIFF_C    = 3,      AIFF-C sound file
  FTW_NH_EB     = 4 +  0, Headerless file (big-endian byte order)
  FTW_NH_EL     = 4 + 16, Headerless file (little-endian byte order)
  FTW_NH_NATIVE = 4 + 32, Headerless file (native byte order)
  FTW_NH_SWAP   = 4 + 48, Headerless file (byte-swapped byte order)
  FTW_AIFF      = 5,      AIFF sound file
.fi
.ft P
.ti -4n
 -> int Dformat
.br
Data format code
.ft CW
.nf
.ne 3
  FD_MULAW8  = 1,  mu-law 8-bit data
  FD_ALAW8   = 2,  A-law 8-bit data
  FD_UINT8   = 3,  offset-binary 8-bit integer data
  FD_INT8    = 4,  two's-complement 8-bit integer data
  FD_INT16   = 5,  two's-complement 16-bit integer data
  FD_INT24   = 6,  two's-complement 24-bit integer data
  FD_INT32   = 7,  two's-complement 32-bit integer data
  FD_FLOAT32 = 8,  32-bit floating-point data
  FD_FLOAT64 = 9,  64-bit floating-point data
  FD_TEXT    = 10,  text data
.fi
.ft P
.ti -4n
 -> long int Nchan
.br
Number of channels
.ti -4n
 -> double Sfreq
.br
Sampling frequency
.ti -4n
 -> FILE *fpinfo
.br
File pointer for printing audio file information.  If fpinfo is not NULL,
information about the audio file is printed on the stream selected by
fpinfo.
.in -4n
.SH Author / revision
P. Kabal
/ Revision 1.8  2009/03/01
.SH See Also
AFclose,
AFdWriteData,
AFfWriteData,
AFsetHinfo,
AFsetSpeaker
